package com.alibaba.citrus.cr.sales.plan.sdo;

import com.alibaba.citrus.cr.common.util.CalculatePercentage;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @author luyi
 * @date 2021/10/13 3:48 下午
 */
public abstract class SalesPlanStatSDO implements Serializable {

    private static final long serialVersionUID = -4710239667219773331L;
    /**
     * 月度计划ID
     */
    private String planId;

    /**
     * 月度计划号
     */
    private String planNo;

    /**
     * 月份合同量
     */
    private Integer monthContractCount;

    /**
     * 折后合同金额
     */
    private Long monthContractMoney;

    /**
     * 折前合同金额
     */
    private Long beforeMonthContractMoney;

    /**
     * 计划量
     */
    private Integer monthCount;

    /**
     * 折后计划金额
     */
    private Long monthMoney;

    /**
     * 折前计划金额
     */
    private Long beforeMonthMoney;

    /**
     * 初始任务量
     */
    private Integer initTaskCount;

    /**
     * 初始折后任务金额
     */
    private Long initTaskMoney;

    /**
     * 初始折前任务金额
     */
    private Long initBeforeTaskMoney;

    /**
     * 任务量
     */
    private Integer taskCount;

    /**
     * 折后任务金额
     */
    private Long taskMoney;

    /**
     * 折前任务金额
     */
    private Long beforeTaskMoney;

    /**
     * 当月度计划状态为
     * 待锁定：   合同差量=month_count（计划数量）-month_contract_count（合同量） \
     * 状态已发布：合同差量 = 任务量 - 合同量
     */
    private Integer contractDifferenceCount;

    /**
     * 折后满足度 = 折后计划金额/折后合同金额
     */
    private BigDecimal contractSatisfaction;

    /**
     * 折前满足度=折前计划金额/折前合同金额
     */
    private BigDecimal beforeContractSatisfaction;

    /**
     * 调整量
     */
    private Integer adjustCount;
    /**
     * 折后调整金额
     */
    private Long adjustMoney;
    /**
     * 折前调整金额
     */
    private Long beforeAdjustMoney;

    /**
     * 上旬计划量
     */
    private Integer monthFirstCount;

    /**
     * 上旬回复量
     */
    private Integer monthFirstReturnCount;

    /**
     * 上旬任务量
     */
    private Integer monthFirstTaskCount;

    /**
     * 上旬调整量
     */
    private Integer monthFirstAdjustCount;

    /**
     * 上旬调整回复量
     */
    private Integer monthFirstAdjustReturnCount;

    /**
     * 上旬调整总量
     */
    private Integer monthFirstAdjustTotalCount;

    /**
     * 中旬计划量
     */
    private Integer monthMiddleCount;

    /**
     * 中旬回复量
     */
    private Integer monthMiddleReturnCount;

    /**
     * 中旬任务量
     */
    private Integer monthMiddleTaskCount;

    /**
     * 中旬调整量
     */
    private Integer monthMiddleAdjustCount;

    /**
     * 中旬调整回复量
     */
    private Integer monthMiddleAdjustReturnCount;

    /**
     * 中旬调整总量
     */
    private Integer monthMiddleAdjustTotalCount;

    /**
     * 下旬计划量
     */
    private Integer monthLastCount;

    /**
     * 下旬回复量
     */
    private Integer monthLastReturnCount;

    /**
     * 下旬任务量
     */
    private Integer monthLastTaskCount;

    /**
     * 下旬调整量
     */
    private Integer monthLastAdjustCount;

    /**
     * 下旬调整回复量
     */
    private Integer monthLastAdjustReturnCount;

    /**
     * 下旬调整总量
     */
    private Integer monthLastAdjustTotalCount;

    private Integer m1RollingPlanCount;

    private Integer m1RollingReturnCount;

    private Integer m2RollingPlanCount;

    private Integer m2RollingReturnCount;

    private Integer m3RollingPlanCount;

    private Integer m3RollingReturnCount;

    /**
     * 1：待锁定   2：待回复   3：待发布   4：已发布   5：调整中
     */
    private Integer status;

    private String features;

    private Integer monthReturnCount;

    private Long monthReturnMoney;

    private Long beforeMonthReturnMoney;

    private Integer monthAdjustReturnCount;

    private Long monthAdjustReturnMoney;

    private Long beforeMonthAdjustReturnMoney;

    private Integer monthAdjustTotalCount;

    private Long monthAdjustTotalMoney;

    private Long beforeMonthAdjustTotalMoney;

    public Long getMonthReturnMoney() {
        return monthReturnMoney;
    }

    public void setMonthReturnMoney(Long monthReturnMoney) {
        this.monthReturnMoney = monthReturnMoney;
    }

    public Long getBeforeMonthReturnMoney() {
        return beforeMonthReturnMoney;
    }

    public void setBeforeMonthReturnMoney(Long beforeMonthReturnMoney) {
        this.beforeMonthReturnMoney = beforeMonthReturnMoney;
    }

    public Long getMonthAdjustReturnMoney() {
        return monthAdjustReturnMoney;
    }

    public void setMonthAdjustReturnMoney(Long monthAdjustReturnMoney) {
        this.monthAdjustReturnMoney = monthAdjustReturnMoney;
    }

    public Long getBeforeMonthAdjustReturnMoney() {
        return beforeMonthAdjustReturnMoney;
    }

    public void setBeforeMonthAdjustReturnMoney(Long beforeMonthAdjustReturnMoney) {
        this.beforeMonthAdjustReturnMoney = beforeMonthAdjustReturnMoney;
    }

    public Integer getMonthAdjustTotalCount() {
        return monthAdjustTotalCount;
    }

    public void setMonthAdjustTotalCount(Integer monthAdjustTotalCount) {
        this.monthAdjustTotalCount = monthAdjustTotalCount;
    }

    public Long getMonthAdjustTotalMoney() {
        return monthAdjustTotalMoney;
    }

    public void setMonthAdjustTotalMoney(Long monthAdjustTotalMoney) {
        this.monthAdjustTotalMoney = monthAdjustTotalMoney;
    }

    public Long getBeforeMonthAdjustTotalMoney() {
        return beforeMonthAdjustTotalMoney;
    }

    public void setBeforeMonthAdjustTotalMoney(Long beforeMonthAdjustTotalMoney) {
        this.beforeMonthAdjustTotalMoney = beforeMonthAdjustTotalMoney;
    }

    private Long monthFirstAdjustReturnMoney;

    private Long monthMiddleAdjustReturnMoney;

    private Long monthLastAdjustReturnMoney;

    public Long getMonthFirstAdjustReturnMoney() {
        return monthFirstAdjustReturnMoney;
    }

    public void setMonthFirstAdjustReturnMoney(Long monthFirstAdjustReturnMoney) {
        this.monthFirstAdjustReturnMoney = monthFirstAdjustReturnMoney;
    }

    public Long getMonthMiddleAdjustReturnMoney() {
        return monthMiddleAdjustReturnMoney;
    }

    public void setMonthMiddleAdjustReturnMoney(Long monthMiddleAdjustReturnMoney) {
        this.monthMiddleAdjustReturnMoney = monthMiddleAdjustReturnMoney;
    }

    public Long getMonthLastAdjustReturnMoney() {
        return monthLastAdjustReturnMoney;
    }

    public void setMonthLastAdjustReturnMoney(Long monthLastAdjustReturnMoney) {
        this.monthLastAdjustReturnMoney = monthLastAdjustReturnMoney;
    }

    public void setMonthReturnCount(Integer monthReturnCount) {
        this.monthReturnCount = monthReturnCount;
    }

    public Integer getMonthReturnCount() {
        return monthReturnCount;
    }

    public void setMonthAdjustReturnCount(Integer monthAdjustReturnCount) {
        this.monthAdjustReturnCount = monthAdjustReturnCount;
    }

    public Integer getMonthAdjustReturnCount() {
        return monthAdjustReturnCount;
    }
    /**
     * 到岸折前金额
     */
    private Long beforeMonthOutboundMoney;

    public Long getMonthFirstReturnMoney() {
        return monthFirstReturnMoney;
    }

    public Long getMonthMiddleReturnMoney() {
        return monthMiddleReturnMoney;
    }

    public void setMonthFirstReturnMoney(Long monthFirstReturnMoney) {
        this.monthFirstReturnMoney = monthFirstReturnMoney;
    }

    public void setMonthMiddleReturnMoney(Long monthMiddleReturnMoney) {
        this.monthMiddleReturnMoney = monthMiddleReturnMoney;
    }

    public void setMonthLastReturnMoney(Long monthLastReturnMoney) {
        this.monthLastReturnMoney = monthLastReturnMoney;
    }

    public Long getMonthLastReturnMoney() {
        return monthLastReturnMoney;
    }

    /**
     * 到岸折后金额
     */
    private Long monthOutboundMoney;

    private Long monthFirstReturnMoney;

    private Long monthMiddleReturnMoney;

    private Long monthLastReturnMoney;

    public String getPlanId() {
        return planId;
    }

    public void setPlanId(String planId) {
        this.planId = planId;
    }

    public String getPlanNo() {
        return planNo;
    }

    public void setPlanNo(String planNo) {
        this.planNo = planNo;
    }

    public Integer getMonthContractCount() {
        if (monthContractCount == null) {
            return 0;
        }
        return monthContractCount;
    }

    public void setMonthContractCount(Integer monthContractCount) {
        this.monthContractCount = monthContractCount;
    }

    public Long getMonthContractMoney() {
        if (monthContractMoney == null) {
            return 0L;
        }
        return monthContractMoney;
    }

    public void setMonthContractMoney(Long monthContractMoney) {
        this.monthContractMoney = monthContractMoney;
    }

    public Long getBeforeMonthContractMoney() {
        if (beforeMonthContractMoney == null) {
            return 0L;
        }
        return beforeMonthContractMoney;
    }

    public void setBeforeMonthContractMoney(Long beforeMonthContractMoney) {
        this.beforeMonthContractMoney = beforeMonthContractMoney;
    }

    public Integer getMonthCount() {
        if (monthCount == null) {
            return 0;
        }
        return monthCount;
    }

    public void setMonthCount(Integer monthCount) {
        this.monthCount = monthCount;
    }

    public Long getMonthMoney() {
        if (monthMoney == null) {
            return 0L;
        }
        return monthMoney;
    }

    public void setMonthMoney(Long monthMoney) {
        this.monthMoney = monthMoney;
    }

    public Long getBeforeMonthMoney() {
        if (beforeMonthMoney == null) {
            return 0L;
        }
        return beforeMonthMoney;
    }

    public void setBeforeMonthMoney(Long beforeMonthMoney) {
        this.beforeMonthMoney = beforeMonthMoney;
    }

    public Long getBeforeMonthOutboundMoney() {
        if (beforeMonthOutboundMoney == null) {
            return 0L;
        }
        return beforeMonthOutboundMoney;
    }

    public void setBeforeMonthOutboundMoney(Long beforeMonthOutboundMoney) {
        this.beforeMonthOutboundMoney = beforeMonthOutboundMoney;
    }

    public Long getMonthOutboundMoney() {
        if (monthOutboundMoney == null) {
            return 0L;
        }
        return monthOutboundMoney;
    }

    public void setMonthOutboundMoney(Long monthOutboundMoney) {
        this.monthOutboundMoney = monthOutboundMoney;
    }

    public Integer getInitTaskCount() {
        if (initTaskCount == null) {
            return 0;
        }
        return initTaskCount;
    }

    public void setInitTaskCount(Integer initTaskCount) {
        this.initTaskCount = initTaskCount;
    }

    public Long getInitTaskMoney() {
        if (initTaskMoney == null) {
            return 0L;
        }
        return initTaskMoney;
    }

    public void setInitTaskMoney(Long initTaskMoney) {
        this.initTaskMoney = initTaskMoney;
    }

    public Long getInitBeforeTaskMoney() {
        if (initBeforeTaskMoney == null) {
            return 0L;
        }
        return initBeforeTaskMoney;
    }

    public void setInitBeforeTaskMoney(Long initBeforeTaskMoney) {
        this.initBeforeTaskMoney = initBeforeTaskMoney;
    }

    public Integer getTaskCount() {
        if (taskCount == null) {
            return 0;
        }
        return taskCount;
    }

    public void setTaskCount(Integer taskCount) {
        this.taskCount = taskCount;
    }

    public Long getTaskMoney() {
        if (taskMoney == null) {
            return 0L;
        }
        return taskMoney;
    }

    public void setTaskMoney(Long taskMoney) {
        this.taskMoney = taskMoney;
    }

    public Long getBeforeTaskMoney() {
        if (beforeTaskMoney == null) {
            return 0L;
        }
        return beforeTaskMoney;
    }

    public void setBeforeTaskMoney(Long beforeTaskMoney) {
        this.beforeTaskMoney = beforeTaskMoney;
    }

    public Integer getContractDifferenceCount() {
        return contractDifferenceCount;
    }

    public void setContractDifferenceCount(Integer contractDifferenceCount) {
        this.contractDifferenceCount = contractDifferenceCount;
    }

    public BigDecimal getContractSatisfaction() {
        return contractSatisfaction;
    }

    public void setContractSatisfaction(BigDecimal contractSatisfaction) {
        this.contractSatisfaction = contractSatisfaction;
    }

    public BigDecimal getBeforeContractSatisfaction() {
        return beforeContractSatisfaction;
    }

    public void setBeforeContractSatisfaction(BigDecimal beforeContractSatisfaction) {
        this.beforeContractSatisfaction = beforeContractSatisfaction;
    }

    public Integer getAdjustCount() {
        if (adjustCount == null) {
            return 0;
        }
        return adjustCount;
    }

    public void setAdjustCount(Integer adjustCount) {
        this.adjustCount = adjustCount;
    }

    public Integer getMonthFirstCount() {
        return monthFirstCount;
    }

    public void setMonthFirstCount(Integer monthFirstCount) {
        this.monthFirstCount = monthFirstCount;
    }

    public Integer getMonthFirstReturnCount() {
        if (monthFirstReturnCount == null) {
            return 0;
        }
        return monthFirstReturnCount;
    }

    public void setMonthFirstReturnCount(Integer monthFirstReturnCount) {
        this.monthFirstReturnCount = monthFirstReturnCount;
    }

    public Integer getMonthFirstTaskCount() {
        if (monthFirstTaskCount == null) {
            return 0;
        }
        return monthFirstTaskCount;
    }

    public void setMonthFirstTaskCount(Integer monthFirstTaskCount) {
        this.monthFirstTaskCount = monthFirstTaskCount;
    }

    public Integer getMonthFirstAdjustCount() {
        return monthFirstAdjustCount;
    }

    public void setMonthFirstAdjustCount(Integer monthFirstAdjustCount) {
        this.monthFirstAdjustCount = monthFirstAdjustCount;
    }

    public Integer getMonthFirstAdjustReturnCount() {
        if (monthFirstAdjustReturnCount == null) {
            return 0;
        }
        return monthFirstAdjustReturnCount;
    }

    public void setMonthFirstAdjustReturnCount(Integer monthFirstAdjustReturnCount) {
        this.monthFirstAdjustReturnCount = monthFirstAdjustReturnCount;
    }

    public Integer getMonthFirstAdjustTotalCount() {
        return monthFirstAdjustTotalCount;
    }

    public void setMonthFirstAdjustTotalCount(Integer monthFirstAdjustTotalCount) {
        this.monthFirstAdjustTotalCount = monthFirstAdjustTotalCount;
    }

    public Integer getMonthMiddleCount() {
        return monthMiddleCount;
    }

    public void setMonthMiddleCount(Integer monthMiddleCount) {
        this.monthMiddleCount = monthMiddleCount;
    }

    public Integer getMonthMiddleReturnCount() {
        if (monthMiddleReturnCount == null) {
            return 0;
        }
        return monthMiddleReturnCount;
    }

    public void setMonthMiddleReturnCount(Integer monthMiddleReturnCount) {
        this.monthMiddleReturnCount = monthMiddleReturnCount;
    }

    public Integer getMonthMiddleTaskCount() {
        if (monthMiddleTaskCount == null) {
            return 0;
        }
        return monthMiddleTaskCount;
    }

    public void setMonthMiddleTaskCount(Integer monthMiddleTaskCount) {
        this.monthMiddleTaskCount = monthMiddleTaskCount;
    }

    public Integer getMonthMiddleAdjustCount() {
        return monthMiddleAdjustCount;
    }

    public void setMonthMiddleAdjustCount(Integer monthMiddleAdjustCount) {
        this.monthMiddleAdjustCount = monthMiddleAdjustCount;
    }

    public Integer getMonthMiddleAdjustReturnCount() {
        if (monthMiddleAdjustReturnCount == null) {
            return 0;
        }
        return monthMiddleAdjustReturnCount;
    }

    public void setMonthMiddleAdjustReturnCount(Integer monthMiddleAdjustReturnCount) {
        this.monthMiddleAdjustReturnCount = monthMiddleAdjustReturnCount;
    }

    public Integer getMonthMiddleAdjustTotalCount() {
        return monthMiddleAdjustTotalCount;
    }

    public void setMonthMiddleAdjustTotalCount(Integer monthMiddleAdjustTotalCount) {
        this.monthMiddleAdjustTotalCount = monthMiddleAdjustTotalCount;
    }

    public Integer getMonthLastCount() {
        return monthLastCount;
    }

    public void setMonthLastCount(Integer monthLastCount) {
        this.monthLastCount = monthLastCount;
    }

    public Integer getMonthLastReturnCount() {
        if (monthLastReturnCount == null) {
            return 0;
        }
        return monthLastReturnCount;
    }

    public void setMonthLastReturnCount(Integer monthLastReturnCount) {
        this.monthLastReturnCount = monthLastReturnCount;
    }

    public Integer getMonthLastTaskCount() {
        if (monthLastTaskCount == null) {
            return 0;
        }
        return monthLastTaskCount;
    }

    public void setMonthLastTaskCount(Integer monthLastTaskCount) {
        this.monthLastTaskCount = monthLastTaskCount;
    }

    public Integer getMonthLastAdjustCount() {
        return monthLastAdjustCount;
    }

    public void setMonthLastAdjustCount(Integer monthLastAdjustCount) {
        this.monthLastAdjustCount = monthLastAdjustCount;
    }

    public Integer getMonthLastAdjustReturnCount() {
        if (monthLastAdjustReturnCount == null) {
            return 0;
        }
        return monthLastAdjustReturnCount;
    }

    public void setMonthLastAdjustReturnCount(Integer monthLastAdjustReturnCount) {
        this.monthLastAdjustReturnCount = monthLastAdjustReturnCount;
    }

    public Integer getMonthLastAdjustTotalCount() {
        return monthLastAdjustTotalCount;
    }

    public void setMonthLastAdjustTotalCount(Integer monthLastAdjustTotalCount) {
        this.monthLastAdjustTotalCount = monthLastAdjustTotalCount;
    }

    public Integer getM1RollingPlanCount() {
        return m1RollingPlanCount;
    }

    public void setM1RollingPlanCount(Integer m1RollingPlanCount) {
        this.m1RollingPlanCount = m1RollingPlanCount;
    }

    public Integer getM1RollingReturnCount() {
        return m1RollingReturnCount;
    }

    public void setM1RollingReturnCount(Integer m1RollingReturnCount) {
        this.m1RollingReturnCount = m1RollingReturnCount;
    }

    public Integer getM2RollingPlanCount() {
        return m2RollingPlanCount;
    }

    public void setM2RollingPlanCount(Integer m2RollingPlanCount) {
        this.m2RollingPlanCount = m2RollingPlanCount;
    }

    public Integer getM2RollingReturnCount() {
        return m2RollingReturnCount;
    }

    public void setM2RollingReturnCount(Integer m2RollingReturnCount) {
        this.m2RollingReturnCount = m2RollingReturnCount;
    }

    public Integer getM3RollingPlanCount() {
        return m3RollingPlanCount;
    }

    public void setM3RollingPlanCount(Integer m3RollingPlanCount) {
        this.m3RollingPlanCount = m3RollingPlanCount;
    }

    public Integer getM3RollingReturnCount() {
        return m3RollingReturnCount;
    }

    public void setM3RollingReturnCount(Integer m3RollingReturnCount) {
        this.m3RollingReturnCount = m3RollingReturnCount;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getFeatures() {
        return features;
    }

    public void setFeatures(String features) {
        this.features = features;
    }

    public Long getAdjustMoney() {
        if (adjustMoney == null) {
            return 0L;
        }
        return adjustMoney;
    }

    public void setAdjustMoney(Long adjustMoney) {
        this.adjustMoney = adjustMoney;
    }

    public Long getBeforeAdjustMoney() {
        if (beforeAdjustMoney == null) {
            return 0L;
        }
        return beforeAdjustMoney;
    }

    public void setBeforeAdjustMoney(Long beforeAdjustMoney) {
        this.beforeAdjustMoney = beforeAdjustMoney;
    }

    /**
     * 计算计划提报计划量合同占比
     */
    public void calculatePlanSatisfaction() {
        this.contractDifferenceCount = this.getMonthCount() - this.getMonthContractCount();
        this.contractSatisfaction = CalculatePercentage.retainTwo(this.getMonthMoney(), this.getMonthContractMoney());
        this.beforeContractSatisfaction = CalculatePercentage.retainTwo(this.getBeforeMonthMoney(), this.getBeforeMonthContractMoney());
    }

    /**
     * 计算计划提报计划量合同占比
     */
    public void calculatePlanSatisfaction2() {
        this.contractDifferenceCount = this.getMonthCount() - this.getMonthContractCount();
        this.contractSatisfaction = CalculatePercentage.retainTwo(this.getTaskMoney(), this.getMonthContractMoney());
        this.beforeContractSatisfaction = CalculatePercentage.retainTwo(this.getBeforeTaskMoney(), this.getBeforeMonthContractMoney());
    }

    /**
     * 计算计划发布任务量合同占比
     */
    public void calculateTaskSatisfaction() {
        this.contractDifferenceCount = this.getTaskCount() - this.getMonthContractCount();
        this.contractSatisfaction = CalculatePercentage.retainTwo(this.getTaskMoney(), this.getMonthContractMoney());
        this.beforeContractSatisfaction = CalculatePercentage.retainTwo(this.getBeforeTaskMoney(), this.getBeforeMonthContractMoney());
    }

    /**
     * 计划调整任务量+调整量合同占比
     */
    public void calculateAdjustSatisfaction() {
        this.contractDifferenceCount = this.getTaskCount() + this.getAdjustCount() - this.getMonthContractCount();
        this.contractSatisfaction = CalculatePercentage.retainTwo(this.getTaskMoney() + this.getAdjustMoney(), this.getMonthContractMoney());
        this.beforeContractSatisfaction = CalculatePercentage.retainTwo(this.getBeforeTaskMoney() + this.getBeforeAdjustMoney(), this.getBeforeMonthContractMoney());
    }

   /* //调整回复量
    private Integer adjustReturnCount;
    //折前调整回复金额
    private Long beforeAdjustReturnMoney;
    //折后调整回复金额
    private Long adjustReturnMoney;*/

    /**
     * 调整发布计算
     *
     * @param costInsuranceFreight
     * @param estimateDiscount
     */
    public void calculateAdjustPublicSatisfaction(Long costInsuranceFreight, BigDecimal estimateDiscount) {
        Integer adjustReturnCount = this.getMonthFirstAdjustReturnCount() + this.getMonthMiddleAdjustCount() + this.getMonthLastAdjustCount();
        //调整回复量
        Long beforeAdjustReturnMoney = (adjustReturnCount + this.taskCount) * costInsuranceFreight;
        //折前调整回复金额
        BigDecimal multiply = estimateDiscount.multiply(new BigDecimal("0.01").setScale(2, BigDecimal.ROUND_HALF_UP));
        BigDecimal subtract = new BigDecimal(1).subtract(multiply);
        Long adjustReturnMoney = new BigDecimal(this.getBeforeAdjustMoney()).multiply(subtract).longValue();
        //折后调整回复金额
        this.taskCount = this.getTaskCount() + adjustReturnCount;
        this.taskMoney = this.getTaskMoney() + adjustReturnMoney;
        this.beforeTaskMoney = this.getBeforeTaskMoney() + beforeAdjustReturnMoney;
        calculateTaskSatisfaction();
    }

    /**
     * 计算折后到岸金额
     *
     * @param estimateDiscount 计划折后率
     */
    public void calculateMonthOutboundMoney(BigDecimal estimateDiscount) {
        BigDecimal multiply = estimateDiscount.multiply(new BigDecimal("0.01").setScale(2, BigDecimal.ROUND_HALF_UP));
        BigDecimal subtract = new BigDecimal(1).subtract(multiply);
        this.setMonthOutboundMoney(new BigDecimal(this.getBeforeMonthOutboundMoney()).multiply(subtract).longValue());
    }

    /**
     * 计算折后计划金额
     *
     * @param estimateDiscount 计划折后率
     */
    public void calculateMonthMoney(BigDecimal estimateDiscount) {
        BigDecimal multiply = estimateDiscount.multiply(new BigDecimal("0.01").setScale(2, BigDecimal.ROUND_HALF_UP));
        BigDecimal subtract = new BigDecimal(1).subtract(multiply);
        this.setMonthMoney(new BigDecimal(this.getBeforeMonthMoney()).multiply(subtract).longValue());
    }

    /**
     * 计算折后任务金额
     *
     * @param estimateDiscount 计划折后率
     */
    public void calculateTaskMoney(BigDecimal estimateDiscount) {
        BigDecimal multiply = estimateDiscount.multiply(new BigDecimal("0.01").setScale(2, BigDecimal.ROUND_HALF_UP));
        BigDecimal subtract = new BigDecimal(1).subtract(multiply);
        this.setTaskMoney(new BigDecimal(this.getBeforeTaskMoney()).multiply(subtract).longValue());
    }

    /**
     * 计算折后调整金额
     *
     * @param estimateDiscount 计划折后率
     */
    public void calculateAdjustMoney(BigDecimal estimateDiscount) {
        BigDecimal multiply = estimateDiscount.multiply(new BigDecimal("0.01").setScale(2, BigDecimal.ROUND_HALF_UP));
        BigDecimal subtract = new BigDecimal(1).subtract(multiply);
        this.setAdjustMoney(new BigDecimal(this.getBeforeAdjustMoney()).multiply(subtract).longValue());
    }

    /**
     * 折前满足度=（任务量+调整回复量）*货品常规价：合同量
     * 折后满足度=（任务量+调整回复量）*货品常规价*（1-预估价格折扣率）：合同量
     * (发布后)
     * @param costInsuranceFreight 货品常规价
     * @param estimateDiscount     预估价格折扣率
     */
    public void calculateTaskReturnSatisfaction(Long costInsuranceFreight, BigDecimal estimateDiscount) {
        //折前满足度 start
        //任务量
        Integer taskCount = this.getTaskCount();
        //调整回复量
        Integer monthAdjustReturnCount = this.getMonthFirstAdjustReturnCount() + this.getMonthMiddleAdjustReturnCount() + this.getMonthLastAdjustReturnCount();
        //折前
        BigDecimal beforeContractSatisfaction = new BigDecimal(monthAdjustReturnCount).add(new BigDecimal(taskCount)).multiply(new BigDecimal(costInsuranceFreight));
        this.beforeContractSatisfaction = CalculatePercentage.retainTwoBigDecimal(beforeContractSatisfaction, new BigDecimal(this.getMonthContractMoney()));
        //折前满足度 end

        //折后满足度 start
        BigDecimal multiply = estimateDiscount.multiply(new BigDecimal("0.01").setScale(2, BigDecimal.ROUND_HALF_UP));
        BigDecimal subtract = new BigDecimal(1).subtract(multiply);
        BigDecimal contractSatisfaction = beforeContractSatisfaction.multiply(subtract);
        this.contractSatisfaction = CalculatePercentage.retainTwoBigDecimal(contractSatisfaction, new BigDecimal(this.getMonthContractMoney()));
        //折后满足度 end
    }

    /**
     * 计算任务金额
     * 折前任务金额=（任务量+调整回复量）*货品常规价
     * 折后任务金额=（任务量+调整回复量）*货品常规价*（1-预估价格折扣率）
     * (发布后)
     * @param costInsuranceFreight 货品常规价
     * @param estimateDiscount     预估价格折扣率
     */
    public void calculateTaskReturnMoney(Long costInsuranceFreight, BigDecimal estimateDiscount) {
        //折前任务金额 start
        //任务量
        Integer taskCount = this.getTaskCount();
        //调整回复量
        Integer monthAdjustReturnCount = this.getMonthFirstAdjustReturnCount() + this.getMonthMiddleAdjustReturnCount() + this.getMonthLastAdjustReturnCount();
        //折前
        //Long beforeAdjustMoney = monthAdjustReturnCount + taskCount * costInsuranceFreight;
        Long beforeAdjustMoney = taskCount * costInsuranceFreight;
        this.beforeAdjustMoney = beforeAdjustMoney;
        //折前任务金额 end

        //折后任务金额 start
        BigDecimal multiply = estimateDiscount.multiply(new BigDecimal("0.01").setScale(2, BigDecimal.ROUND_HALF_UP));
        BigDecimal subtract = new BigDecimal(1).subtract(multiply);
        Long adjustMoney = new BigDecimal(this.beforeAdjustMoney).multiply(subtract).longValue();
        this.adjustMoney = adjustMoney;
        //折后任务金额 end
    }

    /**
     * 折前满足度=（任务量+调整提报量）*货品常规价：合同量
     * 折后满足度=（任务量+调整提报量）*货品常规价*（1-预估价格折扣率）：合同量
     * (发布前)
     * @param costInsuranceFreight 货品常规价
     * @param estimateDiscount     预估价格折扣率
     */
    public void calculateMonthSatisfaction(Long costInsuranceFreight, BigDecimal estimateDiscount) {
        //折前满足度 start
        //任务量
        Integer taskCount = this.getTaskCount();
        //调整提报量
        Integer monthAdjustCount = this.getMonthFirstAdjustCount() + this.getMonthMiddleAdjustCount() + this.getMonthLastAdjustCount();
        //折前
        BigDecimal beforeContractSatisfaction = new BigDecimal(monthAdjustCount).add(new BigDecimal(taskCount)).multiply(new BigDecimal(costInsuranceFreight));
        this.beforeContractSatisfaction = CalculatePercentage.retainTwoBigDecimal(beforeContractSatisfaction, new BigDecimal(this.getMonthContractMoney()));
        //折前满足度 end

        //折后满足度 start
        BigDecimal multiply = estimateDiscount.multiply(new BigDecimal("0.01").setScale(2, BigDecimal.ROUND_HALF_UP));
        BigDecimal subtract = new BigDecimal(1).subtract(multiply);
        BigDecimal contractSatisfaction = beforeContractSatisfaction.multiply(subtract);
        this.contractSatisfaction = CalculatePercentage.retainTwoBigDecimal(contractSatisfaction, new BigDecimal(this.getMonthContractMoney()));
        //折后满足度 end
    }

    /**
     * 计算折后任务金额
     * 折前任务金额=（任务量+调整提报量）*货品常规价
     * 折后任务金额=（任务量+调整提报量）*货品常规价*（1-预估价格折扣率）
     * (发布前)
     * @param costInsuranceFreight 货品常规价
     * @param estimateDiscount     预估价格折扣率
     */
    public void calculateMonthMoney(Long costInsuranceFreight, BigDecimal estimateDiscount) {
        //折前任务金额 start
        //任务量
        Integer taskCount = this.getTaskCount();
        //调整提报量
        Integer monthAdjustCount = this.getMonthFirstAdjustCount() + this.getMonthMiddleAdjustCount() + this.getMonthLastAdjustCount();
        //折前
        Long beforeAdjustMoney = monthAdjustCount + taskCount * costInsuranceFreight;
        this.beforeAdjustMoney = beforeAdjustMoney;
        //折前任务金额 end

        //折后任务金额 start
        BigDecimal multiply = estimateDiscount.multiply(new BigDecimal("0.01").setScale(2, BigDecimal.ROUND_HALF_UP));
        BigDecimal subtract = new BigDecimal(1).subtract(multiply);
        Long adjustMoney = new BigDecimal(this.beforeAdjustMoney).multiply(subtract).longValue();
        this.adjustMoney = adjustMoney;
        //折后任务金额 end
    }
}
